import $http from "@/utils/http/index";
import type {
  GetCodeReq,
  RegisterReq,
  LoginReq,
  UpdateUserInfoReq,
  GetUserInfoReq,
  UserFeedbackReq,
  IRes
} from "../type/user";

export function getCode(data: GetCodeReq) {
  return $http.get<IRes>({
    url: "/api/user/getCode",
    params: {
      email: data.email,
    },
  });
}

export function register(data: RegisterReq) {
  return $http.post<IRes>({
    url: "/api/user/register",
    data,
  });
}

export function login(data: LoginReq) {
  return $http.post<IRes>({
    url: "/api/user/login",
    data,
  });
}

export function update(data: UpdateUserInfoReq) {
  return $http.patch<IRes>({
    url: "/api/user/updateUserInfo",
    data
  });
}

export function getUserInfo(data: GetUserInfoReq) {
  return $http.get<IRes>({
    url: "/api/user/getUserInfo",
    params: data
  });
}
export function userFeedback(data: UserFeedbackReq) {
  return $http.post<IRes>({
    url: "/api/user/feedback",
    data
  });
}
